草庐IT

python - 测试 SciPy 时出错

全部标签

ruby-on-rails - 在 Rails 环境下使用 Rspec 测试 Rake 任务

我正在尝试测试一个rake任务,它在其中使用了一个事件记录。require'spec_helper'require'rake'loadFile.join(Rails.root,'lib','tasks','survey.rake')describe"surveyraketasks"dodescribe"survey:send_report"doit"shouldsendareport"doRake::Task['survey:send_report'].invokeendendend当我运行此规范rspecspec/lib/survey_spec.rb时,出现此错误“RuntimeEr

ruby - 在 Ubuntu 上安装 ruby​​-odbc gem 时出现 "ERROR: sql.h not found"

尝试在Debian/Ubuntu上安装ruby​​-odbcgem会导致以下错误;“错误:找不到sql.h” 最佳答案 这也发生在OSX上,所以brew来拯救:brewinstallunixodbc 关于ruby-在Ubuntu上安装ruby​​-odbcgem时出现"ERROR:sql.hnotfound",我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/17068590/

ruby-on-rails - 如何使用 RSpec 测试 `rand()`?

我有一个方法可以做这样的事情:defsome_methodchance=rand(4)ifchance==1do#logichereelse#anotherlogichereendend当我用RSpec测试这个方法时,里面的rand(4)总是生成0。我不是在测试Rails的rand方法,我是在测试我的方法.测试我的方法的常见做法是什么? 最佳答案 我会考虑两种方法:方法1:在before:eachblock中使用srand(seed)中已知的种子值:before:eachdosrand(67809)end这适用于所有Ruby版本,并

ruby - 在 OSX 上使用 RVM 安装任何 ruby​​ 版本时出错

伙计们,我要用这个自杀了!我在安装多个Ruby版本的RVM时遇到了一些问题,在关注Stackoverflow上的一个线程后,我决定将其完全删除。重新安装RVM后,我根本无法安装任何Ruby版本。Mac操作系统RVM1.20.10稳定自制软件0.9.4这是一些日志:rvminstall2.0.0-p0或:rvminstall2.0.0-p195--autolibs=enabledSearchingforbinaryrubies,thismighttakesometime.Nobinaryrubiesavailablefor:osx/10.8/x86_64/ruby-2.0.0-p0.Co

ruby-on-rails - 运行 bundle install 时出现 Nokogiri 错误

尝试让克隆的Rails应用程序运行。运行bundleinstall时出现此错误:Usingmini_portile(0.5.0)Installingnokogiri(1.6.0)Gem::InstallError:nokogirirequiresRubyversion>=1.9.2.Anerroroccurredwhileinstallingnokogiri(1.6.0),andBundlercannotcontinue.Makesurethat`geminstallnokogiri-v'1.6.0'`succeedsbeforebundling.但这是rbenvversion的输出:

ruby-on-rails - rspec 路由测试和主机

我看到我可以像这样用rspec测试路由:get("/").shouldroute_to("welcome#index")但我有基于主机名或部分主机名的约束,并在多个主机名之间重定向。测试时如何指定主机名?如何使用正确的配置运行测试?我尝试打印root_url并得到:Missinghosttolinkto!Pleaseprovidethe:hostparameter,setdefault_url_options[:host],orset:only_pathtotrue 最佳答案 同样的错误发生在我每次运行rspecspec/整个错误实

ruby-on-rails - 如果我调用 Factory.build 以使我的 Controller 测试快速,我怎样才能让 Factory Girl 永远不会访问数据库?

我正在寻求使我的Rails测试更快。我只有520个测试,但它们在bash中运行需要62秒,在Rubymine中运行需要82秒。作为典型Controller测试的示例,我使用此代码以@user身份登录并在CommentsController中为我的RSpecController测试创建基本的@comment:before(:each)do@user=Factory.create(:user)sign_in@user@comment=Factory.create(:comment)end您可能会意识到...这很慢。它构建了一个@user,但也为该用户构建了关联。@comment也是如此。所

ruby - 如何清除 ruby​​ 中 rspec 测试之间的类变量

我有以下类(class):我想确保类url只为所有实例设置一次。classDataFactory@@url=nildefinitialize()beginif@@url.nil?Rails.logger.debug"Settingurl"@@url=MY_CONFIG["myvalue"]endrescueExceptionraiseDataFactoryError,"Error!"endendend我有两个测试:it"shouldlogamessage"doAPP_CONFIG={"myvalue"=>"test"}Rails.stub(:logger).and_return(log

ruby-on-rails - 如何在 rspec 功能测试中访问(设计)current_user?

在设计文档中,他们提供了有关在测试Controller时如何访问current_user的提示:https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29但是,在进行功能测试时呢?我正在尝试测试我的一个Controller的创建方法,并且在该Controller中使用了current_user变量。问题是devise中建议的宏使用了@request变量,并且对于功能规范来说它是nil。什么是解决方法?编辑:这是我目前的规范:feature

ruby-on-rails - Cucumber 是否不需要编写单元测试?

我对可用于Ruby/ROR的测试框架的数量感到有点困惑。我最近看了CucumberRailscasts并发现它们非常有趣。所以我开始玩游戏,然后努力从概念上看我应该在哪里进行各种测试。似乎很有可能在Cucumber中完成所有可以在单元测试中完成的事情,所以我是否需要编写单元测试,或者我应该只编写我的功能定义并专注于提供尽可能好的覆盖范围开始使用它。我应该使用Rspec还是Test:Unit创建我的单元测试?当我测试Ajax功能时,我应该使用Selenium还是Watir?这里似乎有太多选择,我正在努力寻找使用哪些工具以及边界在哪里。其他人对Cucumber的体验是什么,以及在编写Cuc